import request from '@/utils/request'

// 获取流量统计概览
export function getTrafficOverview(dateRange) {
  return request.get('/management/system/traffic-stats/overview', { params: { dateRange }})
}

// 获取热门内容排行
export function getPopularContent(data, dateRange) {
  // 构建查询参数
  const params = {}
  if (dateRange) {
    params.dateRange = dateRange
  }
  return request.post('/management/system/traffic-stats/popular-content', data, { params })
}

// 获取用户活跃度统计
export function getUserActivity(dateRange) {
  return request.get('/management/system/traffic-stats/user-activity', { params: { dateRange }})
}

// 获取内容流量统计
export function getContentTraffic(dateRange) {
  return request.get('/management/system/traffic-stats/content-traffic', { params: { dateRange }})
}

// 获取内容类型分布
export function getContentTypeStats() {
  return request.get('/management/system/traffic-stats/content-type-stats')
}

// 获取用户增长趋势
export function getUserGrowth(dateRange) {
  return request.get('/management/system/traffic-stats/user-growth', { params: { dateRange }})
}

// 导出流量统计数据
export function exportTrafficStats(dateRange) {
  return request.get('/management/system/traffic-stats/export', {
    params: { dateRange },
    responseType: 'blob'
  })
}
